package org.idea.spring.condition.propertyinject;

import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author linhao
 * @Date created in 11:04 上午 2021/5/8
 */
@Configuration
public class MyConfig {

    @Bean
    public MyResourceListConfig myResourceListConfig(){
        System.out.println("myResourceListConfig");
        return new MyResourceListConfig();
    }

    @Bean
    @ConditionalOnClass(value = MyResourceListConfig.class)
    @ConditionalOnProperty(name = "my.prop",havingValue = "exist")
    public MyPropertiesConfig myPropertiesConfig(){
        System.out.println("myPropertiesConfig === ");
        return new MyPropertiesConfig();
    }


}
